<template>
  <el-container>
    <el-header>
      <img src="../assets/images/logo.png" alt="" />
      <el-menu background-color="#23262e" text-color="#fff" active-text-color="#409eff" mode="horizontal">
        <el-submenu index="1">
          <template slot="title">
            <el-avatar :src="this.$store.state.user.userinfo.user_pic"> </el-avatar>
            个人中心
          </template>
          <el-menu-item index="1-1">
            <i class="el-icon-s-home"></i>
            <span>基本信息</span>
          </el-menu-item>
          <el-menu-item index="1-2">
            <i class="el-icon-s-home"></i>
            <span>更换头像</span>
          </el-menu-item>
          <el-menu-item index="1-3">
            <i class="el-icon-s-home"></i>
            <span>重置密码</span>
          </el-menu-item>
        </el-submenu>
        <el-menu-item index="2">退出</el-menu-item>
      </el-menu>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          background-color="#23262e"
          text-color="#fff"
          active-text-color="#409eff"
          default-active="1"
          class="el-menu-vertical-demo"
          unique-opened
        >
          <el-menu-item class="user">
            <el-avatar :src="this.$store.state.user.userinfo.user_pic"> </el-avatar>
            &nbsp;&nbsp; {{ this.$store.state.user.userinfo.nickname || this.$store.state.user.userinfo.username }}
          </el-menu-item>
          <el-menu-item index="1">
            <i class="el-icon-s-home"></i>
            <span slot="title">首页</span>
          </el-menu-item>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-s-data"></i>
              <span>文章管理</span>
            </template>
            <el-menu-item index="2-1">文章分类</el-menu-item>
            <el-menu-item index="2-2">文章列表</el-menu-item>
          </el-submenu>

          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-s-custom"></i>
              <span>个人中心</span>
            </template>
            <el-menu-item index="3-1" @click="$router.push('/user-info')">基本资料</el-menu-item>
            <el-menu-item index="3-2">修改头像</el-menu-item>
            <el-menu-item index="3-3">重置密码</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
// import { userinfoAPI } from '../axios/api.js'
export default {
  data() {
    return {
      src: this.$store.state.user.user_pic
    }
  },
  created() {
    this.$store.dispatch('user/getUser')
  }
}
</script>

<style lang="less">
.el-container {
  height: 100%;
  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #23262e;
  }
  .el-aside {
    background-color: #23262e;
    .user {
      text-align: center;
    }
  }
  .el-footer {
    background-color: #eee;
  }
}
</style>
